package com.wzm.moviepic.fragment;

import java.io.File;
import java.util.ArrayList;

import net.tsz.afinal.FinalBitmap;

import com.wzm.bean.AboutUsInfo;
import com.wzm.bean.DownInfo;
import com.wzm.bean.HistoryBean;
import com.wzm.bean.MovieInfo;
import com.wzm.db.DBHelper;
import com.wzm.manager.AppConfig;
import com.wzm.manager.AppManager;
import com.wzm.moviepic.R;
import com.wzm.utils.FileUtils;
import com.wzm.utils.Logger;
import com.wzm.utils.UtilsTools;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

public class AboutUsAdapter extends BaseAdapter {
	
	private ArrayList<AboutUsInfo> mList = null;
	private Context mContext = null;
	private LayoutInflater  mInflater;
	AboutUsAdapter(Context context,ArrayList<AboutUsInfo> list)
	{
		
		mContext = context;
		mList = list;
		mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);		
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return mList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view = convertView;
		ViewHolder viewHolder = null;
		if(view == null)
		{
			view = mInflater.inflate(R.layout.about_item, parent, false);   
			viewHolder = new ViewHolder();			
			viewHolder.movie_name = (TextView)view.findViewById(R.id.tv_moviename);
			viewHolder.file_size = (TextView)view.findViewById(R.id.tv_filesize);
			viewHolder.img_icon = (ImageView)view.findViewById(R.id.img_icon);
			view.setTag(viewHolder);
		}else{
			viewHolder = (ViewHolder) view.getTag();
		}
		final AboutUsInfo mi = mList.get(position);
		viewHolder.movie_name.setText(mi.getInfo_1());
		viewHolder.file_size.setText(mi.getInfo_2());
		viewHolder.img_icon.setImageResource(mi.getImgid());
		//new Thread(new cutaRunnable(viewHolder.file_size,mi)).start();
		
		
//		viewHolder.btn_del.setOnClickListener(new OnClickListener() {			
//			@Override
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				//删除文件，删除数据库
//				if(FileUtils.DeleteMovieDir(mi.getMovieid()))
//				{
//					long rowid = DBHelper.getInstance(mContext).delDownInfo(mi.getMovieid());
//					if(rowid==1)
//					{
//						mList.remove(mi);
//						notifyDataSetChanged(); 
//						Toast.makeText(mContext, "删除成功", Toast.LENGTH_SHORT).show();
//					}
//				}				
//			}
//		});
		return view;
	}
	
	
	
	private class ViewHolder {
        public TextView  movie_name;  
        public TextView  file_size;
        public ImageView img_icon;
    };
    
   

}
